package com.cty.redis;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;

/**
 * @Auther: cty
 * @Date: 2020/4/8 20:00
 * @Description: 操作redis（无密码）
 * @version: 1.0
 */
public class TestRedis {
    Jedis jedis = null;

    @Before
    public void beforeRedis(){
        jedis = new Jedis("192.168.238.128",6379);
        System.out.println("beforeRedis：已连接Redis数据库");
    }

    @Test
    public void myRedis(){
        // 增
        System.out.println(jedis.set("address","山东"));
        // 查
        System.out.println(jedis.get("address"));
//        // 改
//        System.out.println(jedis.set("address","湖北"));
//        // 删
//        System.out.println(jedis.del("address"));
    }

    @After
    public void afterRedis(){
        jedis.close();
        System.out.println("afterRedis：已关闭Redis数据库连接");
    }
}
